package cn.livingCloud.dto;

import cn.livingCloud.entity.core.ReportRule;
import cn.livingCloud.utils.DateUtils;
import com.alibaba.druid.util.StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by DingJie on 2016/6/27.
 */
public class ReportRuleFormDto {
    protected String createDateTime;
    protected Boolean archive;
    private String uuid;
    private String name;
    //sql
    private String sql;
    //解析内容
    private String content;
    private String deptUuid;
    private String deptName;
    private List<DeptDto> childDept = new ArrayList<>();

    public ReportRuleFormDto() {
    }

    public String getName() {
        return name;
    }

    public String getCreateDateTime() {
        return createDateTime;
    }

    public void setCreateDateTime(String createDateTime) {
        this.createDateTime = createDateTime;
    }

    public Boolean getArchive() {
        return archive;
    }

    public void setArchive(Boolean archive) {
        this.archive = archive;
    }

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getSql() {
        return sql;
    }

    public void setSql(String sql) {
        this.sql = sql;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getDeptUuid() {
        return deptUuid;
    }

    public void setDeptUuid(String deptUuid) {
        this.deptUuid = deptUuid;
    }

    public String getDeptName() {
        return deptName;
    }

    public void setDeptName(String deptName) {
        this.deptName = deptName;
    }

    public List<DeptDto> getChildDept() {
        return childDept;
    }

    public void setChildDept(List<DeptDto> childDept) {
        this.childDept = childDept;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void loadReportRule(ReportRule reportRule) {
        String value = DateUtils.toDateText(reportRule.getCreateDateTime(), DateUtils.DEFAULT_DATE_TIME_FORMAT);
        if (!StringUtils.isEmpty(value)) {
            this.createDateTime = value;
        }
        this.archive = reportRule.getArchive();
        this.uuid = reportRule.getUuid();
        this.sql = reportRule.getSql();
        this.content = reportRule.getContent();
        this.deptUuid = reportRule.getDeptUuid();
        this.deptName = reportRule.getDept().getName();
        this.name = reportRule.getName();
    }
}
